package com.powerunion.datacollection.common;

import java.util.*;

public class OtherTools {
  private static Random rand = new Random(System.currentTimeMillis());

  public static Random getRandom() {
    return rand;
  }

  /**
   * Generates pseudo-random long from specific range. Generated number is
   * great or equals to min parameter value and less then max parameter value.
   *
   * @param min    lower (inclusive) boundary
   * @param max    higher (exclusive) boundary
   *
   * @return pseudo-random value
   */

  public static long randomLong(long min, long max) {
    return min + (long) (Math.random() * (max - min));
  }

  public static void clearArray(Object arg[]) {
    if (arg == null) {
      return;
    }
    for (int i = 0; i < arg.length; i++) {
      arg[i] = null;
    }
    arg = null;
  }

  /**
   * Generates pseudo-random integer from specific range. Generated number is
   * great or equals to min parameter value and less then max parameter value.
   *
   * @param min    lower (inclusive) boundary
   * @param max    higher (exclusive) boundary
   *
   * @return pseudo-random value
   */
  public static int randomInt(int min, int max) {
    return min + (int) (Math.random() * (max - min));
  }

}
